home *** CD-ROM | disk | FTP | other *** search
/ Mac Easy 2010 May / Mac Life Ubuntu.iso / casper / filesystem.squashfs / usr / lib / xulrunner-1.9.0.14 / chrome / toolkit.jar / content / mozapps / shared / richview.xml
Encoding:
Extensible Markup Language  |  2007-04-03  |  5.3 KB  |  170 lines

  1. <?xml version="1.0"?>
  2.  
  3.  
  4.  
  5. <bindings id="richViewBindings"
  6.           xmlns="http://www.mozilla.org/xbl"
  7.           xmlns:xul="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul"
  8.           xmlns:xbl="http://www.mozilla.org/xbl">
  9.  
  10.   <binding id="richview-item">
  11.     <implementation>
  12.       <method name="fireEvent">
  13.         <parameter name="aEventType"/>
  14.         <body>
  15.         <![CDATA[
  16.           var e = document.createEvent("Events");
  17.           e.initEvent(this.eventPrefix + aEventType, false, true);
  18.           
  19.           this.dispatchEvent(e);
  20.         ]]>
  21.         </body>
  22.       </method>
  23.       
  24.       <property name="disabled" onget="return this.getAttribute('disabled') == 'true'"
  25.                                 onset="this.setAttribute('disabled', val); return val;"/>
  26.     </implementation>  
  27.   </binding>
  28.  
  29.   <binding id="richview">
  30.     <implementation>
  31.       <method name="fireEvent">
  32.         <parameter name="aEventType"/>
  33.         <body>
  34.         <![CDATA[
  35.           var e = document.createEvent("Events");
  36.           var eventType = "richview-" + aEventType;
  37.           e.initEvent(eventType, false, true);
  38.           this.dispatchEvent(e);
  39.           
  40.           var handler = this.getAttribute("onrichview-" + aEventType);
  41.           if (handler != "") {
  42.             var fn = new Function("event", handler);
  43.             fn(e);
  44.           }
  45.           document.commandDispatcher.updateCommands(eventType);
  46.         ]]>
  47.         </body>
  48.       </method>
  49.  
  50.       <field name="_selected">null</field>
  51.       <property name="selected">
  52.         <setter>
  53.         <![CDATA[
  54.           if (this._selected)
  55.             this._selected.removeAttribute("selected");
  56.           this._selected = val;
  57.           if (this._selected)
  58.             this._selected.setAttribute("selected", "true");
  59.           
  60.           this.fireEvent("select");
  61.         ]]>
  62.         </setter>
  63.         <getter>
  64.         <![CDATA[
  65.           return this._selected;
  66.         ]]>
  67.         </getter>
  68.       </property>
  69.       
  70.       <method name="selectForwardInternal">
  71.         <parameter name="aElement"/>
  72.         <body>
  73.         <![CDATA[
  74.           for (var temp = aElement; temp; temp = temp.nextSibling) {
  75.             if ("fireEvent" in temp && !temp.hidden) {
  76.               this.selected = temp;
  77.               break;
  78.             }
  79.           }
  80.         ]]>
  81.         </body>
  82.       </method>
  83.       
  84.       <method name="selectBackwardInternal">
  85.         <parameter name="aElement"/>
  86.         <body>
  87.         <![CDATA[
  88.           for (var temp = aElement; temp; temp = temp.previousSibling) {
  89.             if ("fireEvent" in temp && !temp.hidden) {
  90.               this.selected = temp;
  91.               break;
  92.             }
  93.           }
  94.         ]]>
  95.         </body>
  96.       </method>
  97.       
  98.       <method name="selectionForward">
  99.         <parameter name="aEvent"/>
  100.         <body>
  101.         <![CDATA[
  102.           if (this.selected)
  103.             this.selectForwardInternal(this.selected.nextSibling);
  104.           else {
  105.             if (this.hasChildNodes())
  106.               this.selectForwardInternal(this.firstChild);
  107.           }
  108.         ]]>
  109.         </body>
  110.       </method>
  111.  
  112.       <method name="selectionBackward">
  113.         <parameter name="aEvent"/>
  114.         <body>
  115.         <![CDATA[
  116.           if (this.selected)
  117.             this.selectBackwardInternal(this.selected.previousSibling);
  118.           else {
  119.             if (this.hasChildNodes())
  120.               this.selectBackwardInternal(this.lastChild);
  121.           }
  122.         ]]>
  123.         </body>
  124.       </method>
  125.       
  126.       <property name="children">
  127.         <getter>
  128.         <![CDATA[
  129.           var childNodes = [];
  130.           for (var i = 0; i < this.childNodes.length; ++i) {
  131.             if ("fireEvent" in this.childNodes[i])
  132.               childNodes.push(this.childNodes[i]);
  133.           }
  134.           return childNodes;
  135.         ]]>
  136.         </getter>
  137.       </property>
  138.     </implementation>
  139.     <handlers>
  140.       <handler event="click">
  141.       <![CDATA[
  142.         if (event.ctrlKey) {
  143.           this.selected = null;
  144.           return;
  145.         }
  146.         
  147.         if (event.target == this)
  148.           this.selected = null
  149.         else
  150.           this.selected = event.target;
  151.       ]]>
  152.       </handler>
  153.       <handler event="dblclick" action="if (this.selected && event.button == 0) this.selected.fireEvent('open');"/>
  154.       <handler event="keypress" keycode="VK_ENTER" action="if (this.selected) this.selected.fireEvent('open');"/>
  155.       <handler event="keypress" keycode="VK_RETURN" action="if (this.selected) this.selected.fireEvent('open');"/>
  156.       <handler event="keypress" keycode="VK_UP" action="this.selectionBackward(event);"/>
  157.       <handler event="keypress" keycode="VK_LEFT" action="this.selectionBackward(event);"/>
  158.       <handler event="keypress" keycode="VK_DOWN" action="this.selectionForward(event);"/>
  159.       <handler event="keypress" keycode="VK_RIGHT" action="this.selectionForward(event);"/>
  160.       <handler event="keypress" keycode="VK_UP" modifiers="meta" action="this.selected = null;"/>
  161.       <handler event="keypress" keycode="VK_DOWN" modifiers="meta" action="this.selected = null;"/>
  162.       <handler event="keypress" keycode="VK_LEFT" modifiers="meta" action="this.selected = null;"/>
  163.       <handler event="keypress" keycode="VK_RIGHT" modifiers="meta" action="this.selected = null;"/>
  164.       <handler event="keypress" keycode="VK_DELETE" action="if (this.selected) this.selected.fireEvent('remove');"/>
  165.     </handlers>
  166.   </binding>
  167.   
  168. </bindings>
  169.  
  170.